package cn.com.elite;

import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;

import cn.com.elite.util.Util;

public class mailbean {
	private static final Log log=LogFactory.getLog(mailbean.class);
    private DataSource dataSource;
    private DataSourceTransactionManager tran;
    private PlatformTransactionManager transactionManager;
	public DataSource getDataSource() {
		return dataSource;
	}
	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}
	public DataSourceTransactionManager getTran() {
		return tran;
	}
	public void setTran(DataSourceTransactionManager tran) {
		this.tran = tran;
	}
	public PlatformTransactionManager getTransactionManager() {
		return transactionManager;
	}
	public void setTransactionManager(PlatformTransactionManager transactionManager) {
		this.transactionManager = transactionManager;
	}
	
	public List chaxunList(String sql)throws Exception{
    	List result=new ArrayList();
    	try{
            JdbcTemplate jdbcTemplate=new JdbcTemplate(dataSource); 
            result=jdbcTemplate.queryForList(sql);
    	}catch(Exception e){
    		log.error("chaxunList_sql:"+sql);
    		log.error("chaxunList:"+Util.getERRO(e));
    	}
        return result;
	}
	public int update_sql(String sql)throws Exception{
    	int result=0;
    	try{
            JdbcTemplate jdbcTemplate=new JdbcTemplate(dataSource);
            result=jdbcTemplate.update(sql);
    	}catch(Exception e){
    		log.error("chaxunList_sql:"+sql);
    		log.error("chaxunList:"+Util.getERRO(e));
    	}
        return result;
	}
}
